<?php
namespace App\Libs\Remote;

class SoapClient extends \SoapClient
{
	protected $handler;
	public static function build($wsdl, $opts = array()) {
		$context = stream_context_create($opts);
		$params = array(
			//'encoding' => 'UTF-8', 
			//'verifypeer' => false, 
			//'verifyhost' => false, 
			//'soap_version' => SOAP_1_2, 
			'trace' => 1, 
			'exceptions' => 1, 
			'connection_timeout' => 18000, 
			//'stream_context' => $context,
		);	
		return new self($wsdl, $params);
	}

	public function __soapCall($function_name, $arguments, $options = NULL, $input_headers = NULL, &$output_headers = NULL) {
		//$stime = microtime();
		$ret = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
		//$etime = microtime();
		/*$ss = explode(' ', $stime);
		$ee = explode(' ', $etime);
		$infos = array(
			'time' => date('Y-m-d H:i:s'),
			'func' => $function_name,
			'args' => $arguments,
			'cost' => $ee[0] + $ee[1] - $ss[1] - $ss[0],
		);*/
		//\App\Libs\Log\Logger::info('soap_call', print_r($infos, TRUE));
		return $ret;
	}
}